package cn.tedu.rabbitmqboot.m1;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Producer {

    @Autowired
    private AmqpTemplate amqpTemplate;

    //需要手动调用，发送消息
    public void send(){
        //convertAndSend 将字符串自动转成byte[] 数组，在发送到 helloworld 队列
        amqpTemplate.convertAndSend("helloworld","Hello world!");
        System.out.println("消息已发送");
    }
}
